﻿<!DOCTYPE>
<html>
<head>
    <meta http-equiv="X-UA-Compatible" content="IE=EDGE;IE=11;IE=8,chrome=1" />
    <title>主材消耗定额管理</title>
    <link href="/InSiteWebApplication/Content/Easyui/themes/metro/easyui.css" rel="stylesheet" />
    <link href="/InSiteWebApplication/Content/Easyui/custom-easyui.css" rel="stylesheet" />
    <link href="/InSiteWebApplication/Content/Easyui/themes/icon.css" rel="stylesheet" />
    <link rel="stylesheet" href="/InSiteWebApplication/Content/webuploader/webuploader.css" />
    <style type="text/css">
        .l-btn2
        {
            border: #d2d2d2 1px solid;
            font-family: Tahoma, Helvetica;
            font-size: 10px;
            cursor: pointer;
            font-weight: 500;
            text-decoration: none;
            height: 26px;
            color: #fff;
            background: #02bfbf;
        }
        .l-btn2:hover
        {
            color: #fff;
            background: #05d2d2;
        }
        .btnNews
        {
            height: 20px;
            width: 50px;
            text-align: center;
            text-decoration: none;
            display: inline-block;
            font-size: 9px;
            margin: 2px 2px;
            cursor: pointer;
            color: Black;
            border-radius: 1px;
            box-shadow: 0px 1px 0px #3d6b93;
            line-height: 10px;
            text-align: center;
            text-decoration: none;
            transition: background-color 0.15s ease-in-out;
        }
    </style>
</head>
<body>
    <div id="mainSec">
        <div class="panelSection">
            <div class="easyui-panel " title="查询区域" style="padding: 3px; width: 100%" data-options="closable:false,collapsible:true,minimizable:false,maximizable:false">
                <form id="queryForm" action="">
                <div style="margin: 3px 0px 3px 3px">
                    <div style="float: left;">
                        <div class="divLabel" style="margin-bottom: 5px">
                            批次名：</div>
                        <input id="txtContainerName_qf" name="ContainerName" class="easyui-textbox" style="width: 120px;
                            height: 20px" />
                    </div>
                    <div style="float: left; margin-left: 20px">
                        <a id="btnSearch" href='#' class="easyui-linkbutton" style="margin-top: 16px; width: 80px">
                            查询</a> <a id="btnReset" href='#' class="easyui-linkbutton" style="margin-top: 16px;
                                margin-left: 5px;">重置</a>
                    </div>
                    <div style="clear: both">
                    </div>
                </div>
                </form>
            </div>
        </div>
        <div class="panelSection">
            <div class="easyui-panel " title="结果区域" style="padding: 3px; width: 100%" data-options="closable:false,collapsible:true,minimizable:false,maximizable:false">
                <div style="margin: 3px 0px 3px 3px; width: 99%;height:70%">
                    <table id="dgLogInfo" class="easyui-datagrid" style="width: 100%; height: 100%"
                        data-options="fitColumns:true,rownumbers:true">
                    </table>
                </div>
            </div>
        </div>
    </div>
</body>
</html>
<script src="/InSiteWebApplication/Scripts/CustomPageJs/ReferenceJsLib.js" type="text/javascript"></script>
<script src="/InSiteWebApplication/Content/Easyui/jquery.min.js" type="text/javascript"></script>
<script src="/InSiteWebApplication/Content/Easyui/jquery.easyui.min.js" type="text/javascript"></script>
<script src="/InSiteWebApplication/Content/Easyui/easyui-lang-zh_CN.js" type="text/javascript"></script>
<script type="text/javascript" src="/InSiteWebApplication/Content/webuploader/webuploader.js"></script>
<script src="/InSiteWebApplication/Scripts/CustomPageJs/CustomCommon.js" type="text/javascript"></script>
<script type="text/javascript">
    /*
创建人：zhangrj
日期：2024-09-03
描述：热表推送数据中心维护js
*/
var page = {
    rootPath: getRootPath(), //网站根路径
    url: getRootPath() + "/Ashx/ReBiaoConainer/RbSendToDataWenterHandler.ashx",
    //初始化页面
    init: function () {
        page.bind();
    },
    //页面事件绑定
    bind: function () {
        //列表加载
        $("#dgLogInfo").datagrid({
            columns: [[
                 { field: 'ck', title: '选择', checkbox: true },
                 { field: 'TABLENAME', title: '表名', width: 120 },
                 { field: 'UNIQUECOLNAME', title: '列名', width: 120 },
                 { field: 'UNIQUECOLVALUE', title: '列值', width: 120 },
                 { field: 'TYPENAME', title: '类型', width: 120 },
                 { field: 'HANDLENAME', title: '是否推送', width: 150 }
                ]]
        });
        
        //查询按钮
        $('#btnSearch').on("click", function () {
            page.clearPage(false,true);
            page.pageNumber = 1;
            page.searchData();
        });
        //添加按钮
        $('#btnAdd').on("click", function () {
            page.openDialog(false);
        });
        //清除按钮
        $('#btnReset').on("click", function () {
            page.clearPage(true, true);
        });
    },
    //查询
    searchData: function () {
        var params = {
            action: "GetSendRecord"
        };
        var queryFormData = $("#queryForm").serializeArray();
        $.each(queryFormData, function () {
            params[this.name] = this.value;
        });
        if (isNullOrWhiteSpaceStr(params.ContainerName)) {
            displayMessage("批次必填", false);
            return;
        }
        page.post(page.url, params, true, function (res) {
            if (!res.Result) {
                displayMessage(res.Message, res.Result);
                return;
            }
            $("#dgLogInfo").datagrid('loadData', { rows: res.DBTable });
        });
    },
    //删除
    deleteData: function () {
        var selectRow = $("#gdMaterialInfo").datagrid("getChecked");
        if (selectRow.length === 0) {
            displayMessage("请选择数据", false);
            return false;
        }
        var datas = selectRow.map(function (item) {
            return {
                materialID: item.MAINMATERIALSCONSUMEINFOID
            }
        });
        var params = {
            action: "DeleMaterialsConsumeInfoByID",
            datas: JSON.stringify(datas)
        };
        page.post(page.url, params, true, function (res) {
            if (res.Result) {
                page.searchData();
            }
            displayMessage(res.Message, res.Result);
        });
    },
    //打开编辑弹窗
    openDialog: function (isEdit) {
        editPage.materialID = "";
        if (isEdit) { //编辑
            var selectRow = $("#gdMaterialInfo").datagrid("getChecked");
            if (selectRow.length === 0) {
                displayMessage("请选择数据", false);
                return false;
            }
            if (selectRow.length > 1) {
                displayMessage("请选择一条数据进行编辑", false);
                return false;
            }
            editPage.materialID = selectRow[0].MAINMATERIALSCONSUMEINFOID; //记录编辑的数据ID
        }
        page.disableBtn(); //禁用主页面按钮
        $('#dg').dialog({
            onClose: function () {
                page.enableBtn();
            }
        });
        editPage.init();
    },
    //禁用页面按钮
    disableBtn: function () {
        $("#mainSec").find(".easyui-linkbutton").each(function () {
            $(this).linkbutton('disable');
        });
    },
    //启用页面按钮
    enableBtn: function () {
        $("#mainSec").find(".easyui-linkbutton").each(function () {
            $(this).linkbutton('enable');
        });
    },
    //清除页面（查询区域，列表区域）
    clearPage: function (query, list) {
        if (query) {
            $("#txtContainerName_qf").textbox("clear");
        }
        if (list) {
            clearEasyuiDataGrid("dgLogInfo"); //清空列表
        }
    },
    //post数据（路径，参数，是否异步，成功返回方法）
    post: function (url, param, async, callback) {
        $.ajax({
            type: "Post",
            url: url,
            data: param,
            cashe: false,
            async: async,
            dataType: "json",
            beforeSend: function () {
                $.messager.progress({ text: '', msg: '处理中...' });
            },
            success: function (data) {
                $.messager.progress('close');
                callback(data);
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                $.messager.progress('close');
                displayMessage(XMLHttpRequest.responseText, false);
                $("body").find(".easyui-linkbutton").each(function () {
                    $(this).linkbutton('enable');
                });
            }
        });
    }
};
$(function () {
    page.init();
});
</script>
